Skip to content

Commit ab1cdd3

Browse files
authored
Revert "Prewarm LLM cache (#6692)" (#6694)
This reverts commit c055b04.
1 parent c055b04 commit ab1cdd3

File tree

5 files changed

+9
-14
lines changed

5 files changed

+9
-14
lines changed

.env-test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ REUSE_DB=0
2222
ENABLE_ADMIN=True
2323
SET_LOCALE_PATH=False
2424
SECURE_SSL_REDIRECT=False
25+
GOOGLE_APPLICATION_CREDENTIALS=creds
26+
GOOGLE_CLOUD_PROJECT=sumo-test

kitsune/llm/apps.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
from django.apps import AppConfig
2-
from django.conf import settings
32

43

54
class LLMConfig(AppConfig):
65
name = "kitsune.llm"
76
default_auto_field = "django.db.models.AutoField"
8-
9-
def ready(self):
10-
from kitsune.llm.utils import get_llm
11-
12-
if settings.GOOGLE_CLOUD_PROJECT:
13-
# pre-warm the LLM cache
14-
get_llm()

kitsune/llm/questions/classifiers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from kitsune.llm.utils import get_llm
88
from kitsune.products.utils import get_taxonomy
99

10+
DEFAULT_LLM_MODEL = "gemini-2.5-flash-preview-04-17"
1011
HIGH_CONFIDENCE_THRESHOLD = 75
1112
LOW_CONFIDENCE_THRESHOLD = 60
1213

@@ -25,7 +26,7 @@ def classify_question(question: "Question") -> dict[str, Any]:
2526
Analyze a question for spam and, if not spam or low confidence, classify the topic.
2627
Returns a dict with keys: action, spam_result, topic_result (optional).
2728
"""
28-
llm = get_llm()
29+
llm = get_llm(model_name=DEFAULT_LLM_MODEL)
2930

3031
product = question.product
3132
payload: dict[str, Any] = {

kitsune/llm/utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
from functools import lru_cache
1+
from functools import cache
22

33
from langchain.chat_models.base import BaseChatModel
44

5-
DEFAULT_LLM_MODEL = "gemini-2.5-flash-preview-04-17"
65

7-
8-
@lru_cache(maxsize=1)
6+
@cache
97
def get_llm(
10-
model_name: str = DEFAULT_LLM_MODEL,
8+
model_name: str,
119
temperature: int = 1,
1210
max_tokens: int | None = None,
1311
max_retries: int = 2,

kitsune/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,8 @@ def filter_exceptions(event, hint):
13371337

13381338
USER_INACTIVITY_DAYS = config("USER_INACTIVITY_DAYS", default=1095, cast=int)
13391339

1340+
if DEV:
1341+
GOOGLE_APPLICATION_CREDENTIALS = config("GOOGLE_APPLICATION_CREDENTIALS", default="")
13401342
GOOGLE_CLOUD_PROJECT = config("GOOGLE_CLOUD_PROJECT", default="")
13411343

13421344
# shell_plus conf

0 commit comments

Comments
 (0)